/*
* @Author: Someu
* @Date:   2017-12-01 00:01:30
* @Last Modified by:   Someu
* @Last Modified time: 2017-12-04 10:10:29
*/
require('./index.css');
var _mm = require('util/mm.js');
var templateIndex = require('./index.string');
var navSide = {
    option : {
        name : '',
        navList : [
            {name: 'user-center' , desc: '个人中心' , href: './user-center.html'},
            {name: 'order-list'  , desc: '我的订单' , href: './order-list.html'},
            {name: 'pass-update' , desc: '修改密码'  , href: './user-password-update.html'},
            {name: 'about'       , desc: '关于MMall' , href: './about.html'}
        ]
    },
    init : function(option){
        $.extend(this.option,option);
        this.renderNav();
    },
    //渲染导航菜单
    renderNav : function(){
        for(var i=0,iLength = this.option.navList.length;i<iLength;i++){
            if(this.option.navList[i].name === this.option.name){
                this.option.navList[i].isActive = true;
            }
        }
        //渲染list数据
        var navHtml = _mm.renderHtml(templateIndex,{
            navList : this.option.navList
        });
        //html放入容器
        $('.nav-side').html(navHtml);
    }
}
module.exports = navSide;